package android.projet.morpion;

import Controleurs.Controleur;
import Controleurs.ControleurAttente;
import Controleurs.ControleurClient;
import Controleurs.ControleurConnexion;
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.Menu;
import android.view.MenuItem;

public class AndroidActivity extends Activity {
	private Controleur controleur;
	
	private Handler handler;

	/** Called when the activity is first created. */
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        controleur = new ControleurClient(this);
        controleur = new ControleurAttente(this, controleur);
        controleur = new ControleurConnexion(this,controleur);
       
        handler = new Handler()
        {
        	@Override
        	public void handleMessage(Message msg) {
        		controleur.recMessage(msg);}
        };
    }

	@Override
	public void onBackPressed() {
		controleur.touchRetourAction();
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {

		return super.onCreateOptionsMenu(menu);
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		return super.onOptionsItemSelected(item);
	}

	public Handler getHandler() {
		return handler;
	}

	@Override
	protected void onStart() {
		controleur.demarrer();
		super.onStart();
	}
	
	public Controleur getControleur() {
		return controleur;
	}

	public void setControleur(Controleur controleur) {
		this.controleur = controleur;
	}

}